//
//  XOWMOrderLBL.m
//  XOWMSDK
//
//  Created by tucici on 2017/12/5.
//  Copyright © 2017年 SKL. All rights reserved.
//

#import "XOWMOrderLBL.h"
typedef NS_ENUM(NSInteger , OrderLBLType)
{
    titleType = 1,
    imageType
};
@interface XOWMOrderLBL ()
@property (nonatomic, strong) UIView *line;
@property (nonatomic, strong) XOWMLabel *titleLBL;
@property (nonatomic, strong) XOWMImageView *IMG;
@property (nonatomic, strong) XOWMLabel *contentLBL;
@property (nonatomic, strong) XOWMLabel *descrLBL;
@property (nonatomic, assign) OrderLBLType type;
@end
@implementation XOWMOrderLBL

- (instancetype)initWithTitle:(NSString *)title
{
    self = [super init];
    if (self)
    {
        self.titleLBL.text = title;
        self.line.hidden = NO;
        self.type = titleType;
    }
    return self;
}

- (instancetype)initWithImageName:(NSString *)imageName
{
    self = [super init];
    if (self)
    {
//        self.IMG.imageName = imageName;
      UIImage *image = [UIImage imageNamed:@"game_icon.png"];
        self.IMG.image = image;
        self.line.hidden = NO;
        self.type = imageType;
    }
    return self;
}
- (UIView *)line
{
    if (!_line)
    {
        _line = [[UIView alloc]init];
        _line.backgroundColor = RGBA(223, 223, 223, 1.0);
        [self addSubview:_line];
        _line.c_left.equal(self);
        _line.c_right.equal(self);
        _line.c_bottom.equal(self);
        _line.c_height.equal(1);
    }
    return _line;
}

- (XOWMLabel *)contentLBL
{
    if (!_contentLBL)
    {
        _contentLBL = [[XOWMLabel alloc]init];
        _contentLBL.textColor = [UIColor blackColor];
        _contentLBL.font = [UIFont systemFontOfSize:15 weight:UIFontWeightLight];
        [self addSubview:_contentLBL];
    }
    return _contentLBL;
}

- (XOWMLabel *)descrLBL
{
    if (!_descrLBL)
    {
        _descrLBL = [[XOWMLabel alloc]init];
        _descrLBL.textColor = [UIColor lightGrayColor];
        _descrLBL.font = [UIFont systemFontOfSize:13 weight:UIFontWeightLight];
        [self addSubview:_descrLBL];
    }
    return _descrLBL;
}

- (XOWMLabel *)titleLBL
{
    if (!_titleLBL)
    {
        _titleLBL = [[XOWMLabel alloc]init];
        _titleLBL.textColor =  RGBA(109, 109, 109, 1.0);
        _titleLBL.font = [UIFont systemFontOfSize:17 weight:UIFontWeightBold];
        [self addSubview:_titleLBL];
        _titleLBL.c_left.equal(self);
        _titleLBL.c_centerY.equal(self);
        _titleLBL.c_size.equal(self.titleLBL.bounds.size);
    }
    return _titleLBL;
}

- (XOWMImageView *)IMG
{
    if (!_IMG)
    {
        _IMG = [[XOWMImageView alloc]init];
        _IMG.layer.cornerRadius = 5.0;
        _IMG.layer.masksToBounds = YES;
        [self addSubview:_IMG];
        _IMG.c_left.equal(self);
        _IMG.c_centerY.equal(self);
        _IMG.c_size.equal(CGSizeMake(30, 30));
    }
    return _IMG;
}

- (void)setType:(OrderLBLType)type
{
    if (_type != type)
    {
        _type = type;
        if (_type == titleType)
        {
            self.contentLBL.hidden = NO;
            self.contentLBL.c_left.equal(self.titleLBL.c_right).with.coffset(10);
            self.contentLBL.c_centerY.equal(self);
        }
        else
        {
            self.contentLBL.hidden = NO;
            self.descrLBL.hidden = NO;
            self.contentLBL.c_left.equal(self.IMG.c_right).with.coffset(10);
            self.contentLBL.c_bottom.equal(self.c_centerY);
            
            self.descrLBL.c_left.equal(self.IMG.c_right).with.coffset(10);
            self.descrLBL.c_top.equal(self.c_centerY);
            
        }
    }
}
- (void)setContent:(NSString *)content
{
    if (_content != content)
    {
        _content = content;
        self.contentLBL.text = content;
    }
}

- (void)setDescr:(NSString *)descr
{
    if (_descr != descr)
    {
        _descr = descr;
        self.descrLBL.text = descr;
    }
}
/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */


- (void)sp_didUserInfoFailed {
    NSLog(@"Get Info Failed");
}
@end
